//从1开始便利找到最小的数字和前面的交换位置
function fn(nums) {
    let tem, minIndex
    const n = nums.length
    for (let i = 0; i < n; i++) {
        minIndex = i
        for (let j = i + 1; j < n; j++) {
            if (nums[j] < nums[minIndex]) {
                minIndex = j
            }
        }
        if (minIndex !== i) {
            tem = nums[minIndex]
            nums[minIndex] = nums[i]
            nums[i] = tem
        }

    }
    return nums
}
console.log(fn([10, 2, 51, 1, 3, 79, 34]));
